//
// Created by WenYF on 2016/11/2.
//

#ifndef FZJH_BUFFER_H
#define FZJH_BUFFER_H

#include "common.h"
#ifdef __cplusplus  
extern "C" {  
#endif  
// 构造
void* if_buffer_new(int size);
// 释放
void if_buffer_delete(void *buffer);
// return all data array
byte* if_buffer_array(void *buffer);
// limit - position
int if_buffer_remaining(void *buffer);
// 是否还有数据
BOOL if_buffer_hasRemaining(void *buffer);
// position ++
void if_buffer_put(void *buffer, byte one);
// position += length
void if_buffer_putBytes(void *buffer, byte *data, int length);
// position 置为 mark
void if_buffer_reset(void *buffer);
// mark = -1, position = 0
void if_buffer_rewind(void *buffer);
// mark = -1, position = 0, limit = size
void if_buffer_clear(void *buffer);
// mark = position
void if_buffer_mark(void *buffer);
// limit = position, position = 0, mark = -1
void if_buffer_flip(void *buffer);
// position++
byte if_buffer_get(void *buffer);
// position += 2
short if_buffer_getShort(void *buffer);
// position += 4
int if_buffer_getInt(void *buffer);
// position += length
void if_buffer_getBytes(void *buffer, byte *data, int length);
// set position
void if_buffer_setPosition(void *buffer, int position);
// return position
int if_buffer_position(void *buffer);
// return limit
int if_buffer_limit(void *buffer);
// return size
int if_buffer_size(void *buffer);
// print hex
void if_buffer_printHex(void *buffer);

#ifdef __cplusplus  
}  
#endif  
#endif //FZJH_BUFFER_H
